function HandleDialogCustomizeTask(gui, item, options) {
  this._gui = gui;
  this._item = item;
  this._options = options;
  
  this._user = (options && options.user) ? options.user : null;
  this._date = (options && options.date) ? options.date : null;
  this._produces = (options && options.produces) ? options.produces : null;
  this._popupBox = new PopupBox();
  this._createElements();
};

HandleDialogCustomizeTask.prototype._createElements = function() {
  var pos = DOMUtils.findPos(this._gui.assignee);
  var pos1 = [pos[0]+200, pos[1]+100]
  MiscUtils.load(this._popupBox, pos1, ' Loading Data... ');
  
  this._loadData();
};

HandleDialogCustomizeTask.prototype._loadData = function() {
  this._users = null;
  this._others = null;
  this._retrieveUsers();
  this._retrieveOthers();
};

HandleDialogCustomizeTask.prototype._verifyData = function() {
  if (this._users && this._others) {
    this._updateElements();
  }
};

HandleDialogCustomizeTask.prototype._retrieveUsers = function() {
  var _self = this;
  /*new RequestUtils()._read('user', null, null, null, null, null, null, function(result, params) { _self._users = result.data;
                                                                                                  _self._verifyData.call(_self);
                                                                                                }, null);
*/
  new RequestUtils()._mysql('v1user', null, function(result, params) { _self._users = result.data;
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:'customphp/mysqlread.php'});   
};

HandleDialogCustomizeTask.prototype._retrieveOthers = function() {
  var _self = this;
  /*new RequestUtils()._read('user', null, null, null, null, null, null, function(result, params) { _self._others = result.data;
                                                                                                  _self._verifyData.call(_self);
                                                                                                }, { php: Constant.FACTORY + '/jsonread.php' });
*/
  new RequestUtils()._mysql('v1user', null, function(result, params) { _self._others = result.data;
                                                                          _self._verifyData.call(_self);
                                                                        }, {php:Constant.FACTORY + '/customphp/mysqlread.php'});   
};

HandleDialogCustomizeTask.prototype._updateElements = function() {
  var _self = this;
  this._popupBox._close();
  DlmanageUtils.clear(this._gui);
  this._item.orderFlag = Constant.ORDER_TYPE_WEDDING;
  this._item.isCustom = 1;
  this._item.state = 1;
  this._item.title = 'Custom Task';
  this._item.branch = '{{$smarty.const.BRANCH|escape:javascript}}';
  this._item.host = 'http://{{$smarty.const.DOMAIN|escape:javascript}}{{$smarty.const.PATH|escape:javascript}}';
  this._item.pi_trackId = MiscUtils.unique();
  this._item.pi_model = '{{$smarty.const.MODEL_NAME_CUSTOM|escape:javascript}}';
  
  this._gui.cusNo.value = '';
  this._gui.cusNo.onchange = function() { _self._item.customerId = this.value };

  for (var i = 0, il = OrderType.array().length; i < il; i++) {
    var orderType = OrderType.array()[i];
    option = new Option(orderType);
    this._gui.orderType.options[this._gui.orderType.options.length] = option;
    if (option.text == this._item.orderFlag) {
      this._gui.orderType.selectedIndex = this._gui.orderType.options.length - 1;
    }
  }
  this._gui.orderType._index = this._gui.orderType.selectedIndex;
  this._gui.orderType.onchange = function() { _self._item.orderFlag = this.options[this.selectedIndex].text };
  
  this._gui.deadline.value = '';
  this._gui.deadline.onclick = function() { var context = this;
                                            _self._changeDate.call(_self, this, _self._item.deadline, function(sd) { _self._item.deadline = sd; context.focus(); }, false);
                                            return false;
                                          };
  
  this._item.owner = this._user.account;
  this._item.ownerTrackId = this._user.trackId;
  for (var i = 0, il = this._users.length; i < il; i++) {
    var u = this._users[i];
    if (u.type.charAt(0) == '#' || u.type.charAt(0) == '*' || u.type == '{{$smarty.const.USER_TYPE_FREELANCE|escape:javascript}}') {
      continue;
    }
    option = new Option(u.account + ' (' + '{{$smarty.const.BRANCH|escape:javascript}}' + ', ' + u.type + ')');
    option._u = u;
    this._gui.assignee.options[this._gui.assignee.options.length] = option;
    if (option.text == _self._item.account) {
      this._gui.assignee.selectedIndex = this._gui.assignee.options.length - 1;
    }
  }
  
  for (var i = 0, il = this._others.length; i < il; i++) {
    var u = this._others[i];
    if (u.type.charAt(0) != '#') {
      continue;
    }
    option = new Option(u.account + ' (Factory, ' + u.type.substring(1) + ')');
    option._u = u;
    this._gui.assignee.options[this._gui.assignee.options.length] = option;
    if (option.text == _self._item.account) {
      this._gui.assignee.selectedIndex = this._gui.assignee.options.length - 1;
    }
  }
  
  this._item.user_trackId = this._gui.assignee.options[this._gui.assignee.selectedIndex]._u.trackId;
  this._item.user_account = this._gui.assignee.options[this._gui.assignee.selectedIndex]._u.account; 
  this._item.user_password = this._gui.assignee.options[this._gui.assignee.selectedIndex]._u.password;
  this._item.user_name = this._gui.assignee.options[this._gui.assignee.selectedIndex]._u.name;
  this._item.user_email = this._gui.assignee.options[this._gui.assignee.selectedIndex]._u.email;
  this._item.user_type = this._gui.assignee.options[this._gui.assignee.selectedIndex]._u.type;
  this._gui.assignee.onchange = function() { _self._item.user_trackId = this.options[this.selectedIndex]._u.trackId;
                                             _self._item.user_account = this.options[this.selectedIndex]._u.account; 
                                             _self._item.user_password = this.options[this.selectedIndex]._u.password;
                                             _self._item.user_name = this.options[this.selectedIndex]._u.name;
                                             _self._item.user_email = this.options[this.selectedIndex]._u.email;
                                             _self._item.user_type = this.options[this.selectedIndex]._u.type;
                                           };
  
  this._gui.task.value = '';
  this._gui.task.onchange = function() { _self._item.customTask = this.value; };
};

HandleDialogCustomizeTask.prototype._changeDate = function(label, currentDate, onChangeFunc, showTime) {
  var _self = this;
  this._wContainer = document.createElement('div');
  this._wContainer.style.left = DOMUtils.findPos(label)[0] + 'px';
  this._wContainer.style.top = DOMUtils.findPos(label)[1] + 'px';
  this._popupBox._open(this._wContainer, { pos: DOMUtils.findPos(label) });
  
  var ds = new DateSelect(currentDate, null, { container: this._wContainer, showTime: showTime });
  ds._selectFunc = function(sd) { _self._selectDate.call(_self, sd, label, onChangeFunc, showTime); };
};

HandleDialogCustomizeTask.prototype._selectDate = function(sd, label, onChangeFunc, showTime) {
  
  onChangeFunc(sd);
  this._showDate(sd, label, showTime);
  this._popupBox._close();
};

HandleDialogCustomizeTask.prototype._showDate = function(sd, label, showTime) {
  if (sd) { 
    label.value = SimpleDate.format(sd, showTime);
  } else {
    label.value = '';
  }
};